<template>
	<view>
		<block v-if="html_url !== ''">
			<web-view :webview-styles="webviewStyles" :src="html_url"></web-view>
		</block>
		<block v-else-if="img_url !== ''">
			  <u-navbar title="查询报告" leftIconSize="52rpx" leftIconColor="#333" :autoBack="true" :placeholder="true"></u-navbar>
			<view class="jun">
				<image :src="img_url" mode="widthFix"></image>
			</view>

		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				html_url: '',
				img_url: '',
				webviewStyles: {
					progress: {
						color: '#2fcd93'
					}
				}
			}
		},
		onLoad(opt) {
			if (opt.url) {
				let my_url = decodeURIComponent(opt.url);
			     if(this.isImageUrl(my_url)){
					   this.img_url = my_url;
					   uni.setNavigationBarTitle({
					   	title:'车信盟报告'
					   })
				 }else{
					 this.html_url = my_url;
				 }
				this.share.path = '/pages/public/web_view?url=' + encodeURIComponent(my_url);
			}		
		},
		methods:{
			 to_back(){
				this.backTo(); 
			 },
			 isImageUrl(url) {
				 let jpg = '.jpg';
				 let png = '.png';
				 if(url.match(new RegExp(jpg)) !== null || url.match(new RegExp(jpg)) !== null) {   
				       return true;
				 } else {  
					 return false;
				 } 
				
			}
		}
	}
</script>

<style>
	.jun{
		width: 100vw;
		height: auto;
		min-height: 90vh;
	}
	image{
		width: 100%;
		height: 100%;
	}

</style>